<cfoutput>
<%cfcomponent displayname="#root.bean.xmlAttributes.name#" output="false"%>
		<cfloop from="1" to="#arrayLen(root.bean.dbtable.xmlChildren)#" index="i"><%cfproperty name="#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" type="#root.bean.dbtable.xmlChildren[i].xmlAttributes.type#" default="" /%>
		</cfloop>
	<%!---
	PROPERTIES
	---%>
	<%cfset variables.instance = StructNew() /%>

	<%!---
	INITIALIZATION / CONFIGURATION
	---%>
	<%cffunction name="init" access="public" returntype="#root.bean.xmlAttributes.path#" output="false"%>
		<cfloop from="1" to="#arrayLen(root.bean.dbtable.xmlChildren)#" index="i"><%cfargument name="#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" type="<cfif root.bean.dbtable.xmlChildren[i].xmlAttributes.type eq "uuid">uuid<cfelse>string</cfif>" required="false" <cfif root.bean.dbtable.xmlChildren[i].xmlAttributes.type eq "uuid">default="%createUUID()%"<cfelse>default=""</cfif> /%>
		</cfloop>
		<%!--- run setters ---%>
		<cfloop from="1" to="#arrayLen(root.bean.dbtable.xmlChildren)#" index="i"><%cfset set#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#(arguments.#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#) /%>
		</cfloop>
		<%cfreturn this /%>
 	<%/cffunction%>

	<%!---
	PUBLIC FUNCTIONS
	---%>
	<%cffunction name="setMemento" access="public" returntype="#root.bean.xmlAttributes.path#" output="false"%>
		<%cfargument name="memento" type="struct" required="yes"/%>
		<%cfset variables.instance = arguments.memento /%>
		<%cfreturn this /%>
	<%/cffunction%>
	<%cffunction name="getMemento" access="public" returntype="struct" output="false" %>
		<%cfreturn variables.instance /%>
	<%/cffunction%>	<%cffunction name="validate" access="public" returntype="array" output="false"%>
		<%cfset var errors = arrayNew(1) /%>
		<%cfset var thisError = structNew() /%>
		<cfloop from="1" to="#arrayLen(root.bean.dbtable.xmlChildren)#" index="i">
		<%!--- #root.bean.dbtable.xmlChildren[i].xmlAttributes.name# ---%><cfif root.bean.dbtable.xmlChildren[i].xmlAttributes.required eq "Yes" and root.bean.dbtable.xmlChildren[i].xmlAttributes.identity neq true>
		<%cfif (NOT len(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())))%>
			<%cfset thisError.field = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" /%>
			<%cfset thisError.type = "required" /%>
			<%cfset thisError.message = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# is required" /%>
			<%cfset arrayAppend(errors,duplicate(thisError)) /%>
		<%/cfif%></cfif>
		<cfswitch expression="#root.bean.dbtable.xmlChildren[i].xmlAttributes.type#">
		<cfcase value="binary"><%cfif (len(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())) AND NOT isBinary(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())))%>
			<%cfset thisError.field = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" /%>
			<%cfset thisError.type = "invalidType" /%>
			<%cfset thisError.message = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# is not binary" /%>
			<%cfset arrayAppend(errors,duplicate(thisError)) /%>
		<%/cfif%>
		<%cfif (len(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())) GT #root.bean.dbtable.xmlChildren[i].xmlAttributes.length#)%>
			<%cfset thisError.field = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" /%>
			<%cfset thisError.type = "tooLong" /%>
			<%cfset thisError.message = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# is too long" /%>
			<%cfset arrayAppend(errors,duplicate(thisError)) /%>
		<%/cfif%>
		</cfcase>
		<<cfcase value="boolean"><%cfif (len(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())) AND NOT isBoolean(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())))%>
			<%cfset thisError.field = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" /%>
			<%cfset thisError.type = "invalidType" /%>
			<%cfset thisError.message = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# is not boolean" /%>
			<%cfset arrayAppend(errors,duplicate(thisError)) /%>
		<%/cfif%>
		</cfcase>
		<<cfcase value="date"><%cfif (len(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())) AND NOT isDate(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())))%>
			<%cfset thisError.field = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" /%>
			<%cfset thisError.type = "invalidType" /%>
			<%cfset thisError.message = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# is not a date" /%>
			<%cfset arrayAppend(errors,duplicate(thisError)) /%>
		<%/cfif%>
		</cfcase>
		<<cfcase value="numeric"><%cfif (len(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())) AND NOT isNumeric(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())))%>
			<%cfset thisError.field = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" /%>
			<%cfset thisError.type = "invalidType" /%>
			<%cfset thisError.message = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# is not numeric" /%>
			<%cfset arrayAppend(errors,duplicate(thisError)) /%>
		<%/cfif%>
		</cfcase>
		<<cfcase value="string"><%cfif (len(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())) AND NOT IsSimpleValue(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())))%>
			<%cfset thisError.field = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" /%>
			<%cfset thisError.type = "invalidType" /%>
			<%cfset thisError.message = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# is not a string" /%>
			<%cfset arrayAppend(errors,duplicate(thisError)) /%>
		<%/cfif%>
		<%cfif (len(trim(get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#())) GT #root.bean.dbtable.xmlChildren[i].xmlAttributes.length#)%>
			<%cfset thisError.field = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" /%>
			<%cfset thisError.type = "tooLong" /%>
			<%cfset thisError.message = "#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# is too long" /%>
			<%cfset arrayAppend(errors,duplicate(thisError)) /%>
		<%/cfif%>
		</cfcase></cfswitch></cfloop>
		<%cfreturn errors /%>
	<%/cffunction%>	<%!---
	ACCESSORS
	---%><cfloop from="1" to="#arrayLen(root.bean.dbtable.xmlChildren)#" index="i">
	<%cffunction name="set#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" access="public" returntype="void" output="false"%>
		<%cfargument name="#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" type="<cfif root.bean.dbtable.xmlChildren[i].xmlAttributes.type eq "uuid">uuid<cfelse>string</cfif>" required="true" /%>
		<%cfset variables.instance.#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# = arguments.#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# /%>
	<%/cffunction%>
	<%cffunction name="get#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" access="public" returntype="<cfif root.bean.dbtable.xmlChildren[i].xmlAttributes.type eq "uuid">uuid<cfelse>string</cfif>" output="false"%>
		<%cfreturn variables.instance.#root.bean.dbtable.xmlChildren[i].xmlAttributes.name# /%>
	<%/cffunction%>
</cfloop>	<%!---
	DUMP
	---%>
	<%cffunction name="dump" access="public" output="true" return="void"%>
		<%cfargument name="abort" type="boolean" default="false" /%>
		<%cfdump var="%variables.instance%" /%>
		<%cfif arguments.abort%>
			<%cfabort /%>
		<%/cfif%>
	<%/cffunction%>

<%/cfcomponent%>
</cfoutput>
